#include "ImgRebuild.hpp"
#include <memory.h>
#include <stdexcept>

struct RGBptr
{
	char R;
	char G;
	char B;
};

void ImgRebuild::Rebuild(char* originData,int width,int height,int spilt)
{
  if(spilt>width || 0>spilt)
    throw std::logic_error("ImageRebuild Para logic error");

  RGBptr* tempMem=new RGBptr[width];
  RGBptr* ptrOrigin=(RGBptr*)originData;
  for(int i=0;i<height;i++)
  {
    memcpy(tempMem,ptrOrigin+(i*width+spilt),sizeof(RGBptr)*(width-spilt));
    memcpy(tempMem+(width-spilt),ptrOrigin+i*width,spilt*sizeof(RGBptr));
    memcpy(ptrOrigin+(i*width),tempMem,width*sizeof(RGBptr));
  }
  delete [] tempMem;
}
